package com.yinp.proapp.greendao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.github.yuweiguocn.library.greendao.MigrationHelper;
import com.yinp.proapp.module.baidu_map.bean.BaiduMapSearchBean;
import com.yinp.proapp.module.baidu_map.bean.BaiduMapSearchImportanceBean;

import org.greenrobot.greendao.database.Database;

/**
 * Created by Administrator on 2019/1/31 0031.
 */

public class MyOpenHelper extends DaoMaster.OpenHelper {

    public MyOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {

        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        }, LocaleTaskBeanDao.class, BaiduMapSearchBeanDao.class, BaiduMapSearchImportanceBeanDao.class);
    }
}


